 <link href="/public/static/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="/public/static/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="/public/static/plugin/AdminLTE/css/AdminLTE.css" rel="stylesheet" type="text/css" />
    <link href="/public/static/plugin/AdminLTE/css/AdminLTE-singular.css" rel="stylesheet" type="text/css" />

    <!-- 基础自定义css -->
    <link href="/public/static/css/normal.css" rel="stylesheet" type="text/css" />
    <link href="/public/static/plugin/jqueryui/jquery.ui.css" rel="stylesheet" type="text/css" />
    
    <!-- Date Picker -->
    <link href="/public/static/plugin/datetimepicker/bootstrap-datetimepicker.css" rel="stylesheet" type="text/css" />

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->

    <!-- add new calendar event modal -->

    <!-- Start  基础脚本1 -->
    <script src="/public/static/js/jquery.min.js"></script>
    <script src="/public/static/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/public/static/plugin/jqueryui/jquery.ui.js" type="text/javascript"></script>
    <!-- datepicker -->
    <script src="/public/static/plugin/datetimepicker/bootstrap-datetimepicker.js" type="text/javascript"></script>
    <!-- iCheck -->
    <script src="/public/static/plugin/AdminLTE/js/plugins/iCheck/icheck.min.js" type="text/javascript"></script>
    <script src="/public/static/plugin/layer/layer.js"></script>
<style>
table{
		font-size: 12px;
	}
.ncap-account-container-list { font-size: 0; *word-spacing:-1px/*IE6銆�7*/;
vertical-align: top; display: inline-block; *display: inline/*IE7*/;
width: 80%; padding-left: 1%; *zoom: 1;
}
.ncap-account-container-list li { font-size: 13px; line-height: 20px; color: #999; vertical-align: top; letter-spacing: normal; word-spacing: normal; display: inline-block; *display: inline/*IE7*/;
padding-right: 30px; height: 25px; margin-bottom: 5px; *zoom: 1;
}
.checkbox {
    display: unset;
}
.lab{
	position:relative;
	top:-5px;
	left: 5px;
	color: #000000;
}

.box .box-footer{
	padding-bottom: 50px;
	padding-right: 20px;}
</style>

    <{include file='../common_params.tpl'}>
    <input type="hidden" name="id" value="<{$info.id}>" />
    <div class="box box-black">
        <div class="box-body">
            <table class="table table-bordered">
                <colgroup>
                    <col style="width: 20%;"></col>
                    <col style="width: 80%;"></col>
                </colgroup>
                
                <tr>
                    <th class="th-label">所属专服</th>
                    <td>
                        <select class="form-control inline" name="special_id" id="special_id">
                        	<{foreach from=$specialList item=item key=key}>
                        		<option value="<{$key}>" <{if $info.special_id == $key }>selected<{/if}>><{$item}></option>
                        	<{/foreach}>
                        </select>
                    </td>
                </tr>
                
                <tr>
                    <th class="th-label">渠道</th>
                    <td>
                        <div>
                        	<h5>
								<label><{$item.channel_name}></label>
								<input id="cls_full" type="checkbox">
								<label>全部</label>
							</h5>
                        	
                        	<ul class="ncap-account-container-list" id="channel_list">
                        		    <li>
                        		    	<font color="red">请先选择专服</font>
                        		    </li>
							</ul>
                        </div>
                    </td>
                </tr>

                <tr>
                    <th class="th-label-s">服务器状态</th>
                    <td>
                        <{foreach from=$statusList item=item key=key}>
                        <label><input type="radio" name="status" <{if $key == $info.status}>checked<{/if}> value="<{$key}>" /><{$item}></label>
                        <{/foreach}>
                    </td>
                </tr>

                <tr>
                    <th class="th-label">服务器名称</th>
                    <td>
                        <input type="text" name="server_name" class="form-control inline" value="<{$info.server_name}>" placeholder="" />
                    </td>
                </tr>
                
                <!--<tr>
                    <th class="th-label">服号</th>
                    <td>
                        <input type="text" name="server_num" class="form-control inline" value="<{$info.server_num}>" placeholder="" />
                    </td>
                </tr>-->

                <tr>
                    <th class="th-label">开服时间</th>
                    <td><input type="text" name="open_time" value="<{$info.open_time}>" class="form-control inline time" /></td>
                </tr>

            </table>
        </div>

        <div class="box-footer">
            <!--<a href="javascript:history.go(-1);" class="btn btn-default">返回</a>-->
            <button type="submit" name="sub" class="btn btn-default pull-right">保存</button>
        </div>
    </div>


<script>
    $(function(){
        $(".time").datetimepicker({
            format: 'yyyy-mm-dd hh:ii:00',
        });

//      $("#special_id").change(function(){
//          console.log('asdfg');
//      }).change();
        
        var channes = '<{$channes}>';
        var old_special_id = <{$info.special_id}>;
        var channelList = channes.split(",");
        $("#special_id").change(function(){
        	$('#cls_full').iCheck('uncheck');
        	var g = $('input[name="g"]').val();
	        var url = '?r=specialServer/getChannel&g='+g;
	        var special_id = $(this).val();
	        if(special_id == ''){
	        	var html = '<li><font color="red">请先选择专服</font></li>';
	        	$("#channel_list").html(html);
	        	return false;
	        }
            $.ajax({
    	        type : 'POST',
    	        url : url,
		        data : {'special_id':special_id},
		        dataType :'JSON',
		        success : function(res){
			        if(res.status == 1){	
			        	var list = res.data;
			        	var html = '';
			        	for (var i=0;i<list.length;i++){
			        		var ch = '';
			        		if(old_special_id == special_id && channelList.includes(list[i]['id'])){
			        			ch = 'checked';
			        		}
			        		html += '<li><input class="checkbox" '+ch+' name="channel_id[]" value="'+list[i]['id']+'" type="checkbox"><span class="lab">'+list[i]['channel_name']+'</span></li>'
			        	}
			        	$("#channel_list").html(html);
			        }else{
			        	layer.msg(res.msg, {icon: 2});
			        }
		        }
	        });
        }).change();
        
        
        $("#cls_full").click(function(){
        	var vt = $(this).is(':checked');
		    if(vt){
			    $('input[type=checkbox]').prop('checked',vt);
		    }else{
			    $('input[type=checkbox]').removeAttr('checked');
		    }
        });	
        
        
        $('button[name="sub"]').click(function(){
        	var special_id = $('select[name="special_id"]').val();
        	if(special_id == ''){
        		layer.alert('请选择专服', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var arr = new Array();
            $("input[name='channel_id[]']:checkbox[checked]").each(function(i){
                arr[i] = $(this).val();
            });
            var channel = arr.join(",");
            if(channel == ''){
        	    layer.msg('请选择渠道', {icon: 2,time: 2000});
        	    return false;
            }
        	
        	var server_name = $('input[name="server_name"]').val();
        	if(server_name == ''){
        		layer.alert('请填写服务器名称', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var server_num = $('input[name="server_num"]').val();
        	if(server_num == ''){
        		layer.alert('请填写服号', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var id = $('input[name="id"]').val();
        	var status = $('input[name="status"]:checked').val();
        	var open_time = $('input[name="open_time"]').val();
        	
        	var g = $('input[name="g"]').val();
        	var url = '?r=serverApply/apply&g='+g;
        	$.ajax({
    		    type : 'POST',
    		    url : url,
			    data : {'id':id,'special_id':special_id,'channel':channel,'server_name':server_name,'server_num':server_num,'status':status,"open_time":open_time},
			    dataType :'JSON',
			    success : function(res){
				    if(res.status == 1){	
				    	window.parent.call_back();
				    }else{
					    layer.msg('操作失败', {icon: 2,time: 2000});
				    }
			    }
		    });
        	
        	
        });
        
    });
</script>